home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / dev / gui / gui4cli.lha / Gui4Cli / Ext / GCView / gcview.gc < prev    next >
Encoding:
Gui4CLI script  |  1999-12-03  |  11.6 KB  |  516 lines

  1. G4C
  2.  
  3. ; ******************** This is a Gui4Cli gui *********************
  4. ; - You need Gui4Cli version 3.8 to run it 
  5. ; - Get it from Aminet or <http://users.hol.gr/~dck/gcmain.htm>
  6. ; ****************************************************************
  7.  
  8. ; TAB size is 3
  9.  
  10. ; This gui works fine, but it is still a long way from finished.
  11. ; It is mostly a test-bed for gcview with various buttons and no
  12. ; real logic behind it.. I will try to correct this sometime.
  13.  
  14. ; Till then however, it will make gcview easier to use.
  15.  
  16. ; ================================================================
  17.  
  18. WINBIG 14 -10 640 95 ''  ; note -10 for top (see guide)
  19. wintype 00001100
  20. screen GCView
  21. usetopaz
  22. BOX 0 0 640 95 out button
  23.  
  24. xOnLoad
  25.     Local scheight/winheight/barheight
  26.     screentog = 0                ; screen2front toggle
  27.     start        = 0
  28.     frames    = 60
  29.     frtotal   = 60
  30.     file      = ''
  31.     loadall   = ON
  32.     andir     = PINGPONG
  33.     dmode     = BG
  34.     fcount    = 0
  35.     scpos     = 0                ; def screen position (half screen)
  36.     fillmode  = BRUSH            ; def paste fill mode
  37.  
  38.     ; make a hires screen - graphics cards bye-bye..
  39.     makescreen GCView 640/256/3/0x8000 'Gui4Cli Gui 4 GCView by dck@hol.gr'
  40.  
  41.     ; Initialise stuff..
  42.     guiload :gcview.g                    ; load helper routines..
  43.     gosub gcview.g StartGCView        ; start gcview
  44.     gosub gcview.g OpenGCView        ; open window, adjust screen..
  45.     gosub gcview.g InitPalette        ; init palette changer
  46.  
  47.     ; notify keys
  48.     call gcview notify RMB Gui4Cli 'gosub gcview.gc do_rmb'
  49.  
  50.     guiload :gcview.g2                ; load the prefs gui
  51.  
  52. xOnQuit
  53.     guiclose gettext
  54.     guiquit gettext        ; end of gcview.g file
  55.     guiquit gcview.g        ; helper routines
  56.     guiquit gcview.g2        ; prefs gui
  57.     guiclose #this
  58.     killscreen GCView
  59.     call gcview quit force
  60.  
  61. ; -----------------------------------------------------------
  62. ;        RMB & KEY routines
  63. ; -----------------------------------------------------------
  64.  
  65. xOnRMB
  66.     gosub #this do_rmb
  67.  
  68. xRoutine do_rmb ; flip GCView screen front/back
  69.     if $$sys.fsn == GCView
  70.         guiscreen gcview.gc back
  71.     else
  72.         guiscreen gcview.gc front
  73.     endif
  74.  
  75. xOnKey #R
  76.     gosub gcview.g dorawkey
  77.  
  78. xOnKey #V
  79.     gosub gcview.g dovankey
  80.  
  81. ; -----------------------------------------------------------
  82. ;        crop & tile 
  83. ; -----------------------------------------------------------
  84.  
  85. XICON 270 0 :icn/crop
  86.     gadid 50
  87.     call gcview crop mypic
  88.     guiscreen gcview.gc front
  89.  
  90. XICON 363 0 :icn/mtile
  91.     gadid 50
  92.     gosub gcview.g tilepic 1
  93.  
  94. XICON 363 15 :icn/tile
  95.     gadid 50
  96.     gosub gcview.g tilepic 0
  97.  
  98. XICON 363 30 :icn/mirror            ; do 4 way mirror
  99.     gadid 50
  100.     gosub gcview.g 4waymirrtile
  101.  
  102. ; -----------------------------------------------------------
  103. ;        Flip and rotate buttons
  104. ; -----------------------------------------------------------
  105.  
  106. XICON 303 0 :icn/HFlip
  107.     gadid 50
  108.     call gcview flip mypic horizontal
  109.  
  110. XICON 303 15 :icn/VFlip
  111.     gadid 50
  112.     call gcview flip mypic vertical
  113.  
  114. XICON 303 30 :icn/RRotate
  115.     gadid 50
  116.     call gcview rotate mypic right
  117.  
  118. XICON 303 45 :icn/LRotate
  119.     gadid 50
  120.     call gcview rotate mypic left
  121.  
  122.  
  123. ; -----------------------------------------------------------
  124. ;    PAN
  125. ; -----------------------------------------------------------
  126.  
  127. ; ------------- Vertical
  128.  
  129. XICON 333 45 :icn/vpan
  130.     gadid 50
  131.     call gcview pan mypic MIRROR VERTICAL
  132.  
  133. XICON 333 30 :icn/vpanNoMirr
  134.     gadid 50
  135.     call gcview pan mypic VERTICAL
  136.  
  137. ; ------------ Horizintal
  138.  
  139. XICON 333 0 :icn/panNoMirr
  140.     gadid 50
  141.     call gcview pan mypic
  142.  
  143. XICON 333 15 :icn/pan
  144.     gadid 50
  145.     call gcview pan mypic MIRROR
  146.  
  147.  
  148. ; -----------------------------------------------------------
  149. ;    VARIOUS - SAVE, QUIT...
  150. ; -----------------------------------------------------------
  151. ; ------------ normal save
  152.  
  153. XICON 240 30 :icn/save
  154.     gosub gcview.g Save
  155.  
  156. ; ------------ Clear & quit
  157.  
  158. XICON 240 60 :icn/clear
  159.     ; unload all pics and anims (keep palettes)
  160.     call gcview unload #PIC
  161.     call gcview unload #ANIM
  162.  
  163. XICON 240 75 :icn/quit
  164.     local choice
  165.     ezreq 'Quit GCView ?' 'Quit|CANCEL' choice
  166.     if $choice = 1
  167.         guiquit #this
  168.     endif
  169.  
  170. ; -----------------------------------------------------------
  171. ;        The listview
  172. ; -----------------------------------------------------------
  173.  
  174. XLISTVIEW 4 0 210 92 "" file "" 10 DIR
  175.     gadid 1
  176.     gadfont #mono 8 000
  177.     attr lvfilter "~(#?.info)"            ; set filter - no icons
  178.  
  179.     lastfileloaded = $file
  180.  
  181.     if $dmode = D1     ; spare dirs..
  182.         DIR1 = $$lv.dir
  183.     elseif $dmode = D2
  184.         DIR2 = $$lv.dir
  185.     elseif $dmode = D3
  186.         DIR3 = $$lv.dir
  187.     endif
  188.  
  189.     gosub gcview.g showfile
  190.     guiscreen gcview.gc front
  191.     lvmulti none
  192.     lvmove #$$lv.line
  193.     lvmulti on
  194.  
  195.  
  196. xLVDirHook 1
  197.     lvuse #this 1
  198.     setscreentitle #this '$$lv.dir'
  199.  
  200.     if $dmode = D1     ; spare dirs..
  201.         DIR1 = $$lv.dir
  202.     elseif $dmode = D2
  203.         DIR2 = $$lv.dir
  204.     elseif $dmode = D3
  205.         DIR3 = $$lv.dir
  206.     endif
  207.  
  208. ; -----------------------------------------------------------
  209. ;    View selected files
  210. ; -----------------------------------------------------------
  211.  
  212. XICON 240 0 ":icn/View"
  213.     StopView = 0                ; flag to abort viewing
  214.  
  215.     ; install notify command
  216.     call gcview notify V32 Gui4Cli 'gosub gcview.gc ViewNext'
  217.     call gcview notify V13 Gui4Cli 'gosub gcview.gc ViewNext'
  218.  
  219.     lvuse #this 1
  220.     lvmulti first
  221.     gosub #this ViewRtn
  222.     guiscreen gcview.gc back
  223.  
  224. xRoutine ViewNext
  225.     lvuse #this 1
  226.     lvmulti off
  227.     lvmulti next
  228.     gosub #this ViewRtn
  229.     guiscreen gcview.gc back
  230.  
  231. xRoutine ViewRtn    ; actually show the file, or stop
  232.     if $$lv.line > ''
  233.     and $StopView = 0
  234.         gosub gcview.g showfile            ; same routine as the LV itself
  235.     else
  236.         call gcview unload mypic
  237.         call gcview unload #ANIM
  238.         call gcview delnotify V13
  239.         call gcview delnotify V32
  240.         guiscreen gcview.gc front
  241.         stop
  242.     endif
  243.  
  244. ; -----------------------------------------------------------
  245. ;        Delete file
  246. ; -----------------------------------------------------------
  247.  
  248. XICON 240 45 ":icn/Delete"
  249.     lvuse #this 1
  250.     lvaction delete REQ
  251.  
  252. ; -----------------------------------------------------------
  253. ;        listview controls
  254. ; -----------------------------------------------------------
  255.  
  256. XBUTTON 216 0 20 15 "P"
  257.     lvuse #this 1
  258.     lvdir parent
  259.     setscreentitle #this '$$lv.dir'
  260.     
  261. XBUTTON 216 15 20 15 "D"
  262.     lvuse #this 1
  263.     lvdir disks
  264.     setscreentitle #this Devices
  265.  
  266. XBUTTON 216 30 20 15 "A"
  267.     lvuse #this 1
  268.     lvmulti all
  269.  
  270. XBUTTON 216 45 20 15 "N"
  271.     lvuse #this 1
  272.     lvmulti none
  273.  
  274. XBUTTON 216 60 20 15 "<"
  275.     lvuse #this 1
  276.     lvmove -1000
  277.  
  278. XBUTTON 216 75 20 15 "R"
  279.     lvuse #this 1
  280.     lvdir refresh
  281.  
  282. ; ---------------------------------------------------------
  283. ;    status box
  284. ; ---------------------------------------------------------
  285.  
  286. TEXT 411 3 225 14 "Welcome to GCView!" 100 BOX
  287.     gadid 10
  288.  
  289. ; -----------------------------------------------------------
  290. ;        anims
  291. ; -----------------------------------------------------------
  292.  
  293. ;XICON 350 20 :icn/1Anim1
  294. ;    gadid 60
  295.  
  296. ;XICON 350 20 :icn/1Effects0
  297. ;    gadid 60
  298.  
  299. XCHECKBOX 606 57 30 15 "LoadAll" loadall "ON" "OFF" ON
  300.     gadid 2
  301.     if $loadall == ON
  302.         setgad #this 3/4 on
  303.     else
  304.         setgad #this 3/4 off
  305.     endif
  306.  
  307. XHSLIDER 459 18 146 11 "Start" start 0 100 0 "%ld"
  308.     gadid 3
  309.     gosub #this checklength
  310.  
  311. XHSLIDER 459 30 146 11 "Long" frames 0 60 60 "%ld"
  312.     gadid 4
  313.     gosub #this checklength
  314.  
  315. xroutine checklength
  316.     remain = $($frtotal - $start)
  317.     if $frames > $remain
  318.         frames = $remain
  319.         update #this 4 $frames
  320.     endif
  321.  
  322. XICON 546 42 :icn/Backward
  323.     call gcview set direction mypic backward
  324.     andir = BACKWARD
  325.  
  326. XICON 576 42 :icn/forward
  327.     call gcview set direction mypic forward
  328.     andir = FORWARD
  329.  
  330. XICON 606 42 :icn/pingpong
  331.     call gcview set direction mypic ping
  332.     andir = PINGPONG
  333.  
  334. XICON 456 42 ":icn/AddFrame"        ; add a frame
  335.     call gcview addframe mypic
  336.     gosub gcview.g showinfo
  337.  
  338. XICON 486 42 ":icn/DelFrame<"        ; delete frame from end
  339.     call gcview info anim mypic
  340.     info = $$call.ret
  341.     parsevar info
  342.     if $$parse.tot > 1
  343.         call gcview delframe mypic $($$parse.0 - 1) 1
  344.     endif
  345.     gosub gcview.g showinfo
  346.  
  347. XICON 516 42 ":icn/DelFrame>"        ; delete frame from start
  348.     call gcview delframe mypic 0 1
  349.     gosub gcview.g showinfo
  350.  
  351. XICON 240 15 :icn/RRotate            ; RELOAD with new settings
  352.     if $file > ''
  353.         gosub gcview.g playanim 1
  354.         gosub gcview.g showinfo
  355.     endif
  356.  
  357. ; -----------------------------------------------------------
  358. ;        use palette
  359. ; -----------------------------------------------------------
  360.  
  361. XICON 333 75 :icn/palette
  362.     call gcview move pubscreen GCView 0 0 
  363.     ReqFile -1 -1 300 -40 'Choose a palette' LOAD palname ''
  364.     call gcview move pubscreen GCView 0 160
  365.     ifexists file $palname
  366.         call gcview unload mypal
  367.         call gcview load $palname mypal
  368.     endif
  369.  
  370. XCHECKBOX 363 75 26 15 "" usepalette "ON" "" OFF
  371.     gadid 51
  372.     ifexists file ~$palname
  373.         ezreq 'Please choose a palette!\n' "OK" ""
  374.         update #this 51 0
  375.     endif
  376.  
  377. ; -----------------------------------------------------------
  378. ;    zoom to screen
  379. ;    - if there is an edit box, zoom the contents
  380. ;    - otherwise fit the picture to the screen
  381. ; -----------------------------------------------------------
  382.  
  383. XICON 270 15 :icn/Zoom
  384.     gosub gcview.g GetBoxSize
  385.     guiwindow #this wait
  386.     call gcview zoom mypic $x $y $w $h
  387.     guiwindow #this resume
  388.     guiscreen gcview.gc front
  389.  
  390. ; -----------------------------------------------------------
  391. ;    Blend, Erase
  392. ; -----------------------------------------------------------
  393.  
  394. XICON 333 60 :icn/fav      ; was ":icn/Blend"
  395.     ; call gcview BGBlend mypic
  396.     guiopen gcview.g2    ; open prefs gui
  397.  
  398. XICON 363 60 :icn/Blend
  399.     call gcview BGBlend mypic
  400.  
  401. XICON 270 30 ":icn/Erase"
  402.     gosub gcview.g GetBoxSize
  403.     call gcview set pens 0 0 JAM1
  404.     call gcview Rect mypic $x $y $($w + $x) $($h + $y)
  405.  
  406. ; -----------------------------------------------------------
  407. ;    Text
  408. ; -----------------------------------------------------------
  409.  
  410. XICON 270 60 ":icn/Text"
  411.     local txt
  412.     guiopen gettext
  413.  
  414. XICON 270 75 ":icn/Font"
  415.     local txtfont/fontsize
  416.     txtfont = ''
  417.     ReqFile -1 -1 400 -40 'Choose font size:' LOAD txtfont #FONTS:
  418.     if $txtfont > ''
  419.         extract txtfont file fontsize
  420.         extract txtfont path txtfont
  421.         extract txtfont file txtfont
  422.         appvar txtfont .font
  423.         call gcview set font $txtfont $fontsize 000
  424.  
  425.         call gcview set pens 13 3 OUTLINE
  426.  
  427.     endif
  428.  
  429. ; -----------------------------------------------------------
  430. ;    Palette presets handling
  431. ;    - make a list of available palettes & browse through them
  432. ; -----------------------------------------------------------
  433.  
  434. XICON 576 75 :icn/nextpal
  435.     gosub gcview.g NextPalette
  436.  
  437. ; -----------------------------------------------------------
  438. ;  BRUSH - add brush..
  439. ; -----------------------------------------------------------
  440.  
  441. XICON 270 45 ":icn/brush"
  442.     gosub gcview.g pastebrush
  443.  
  444. ; -----------------------------------------------------------
  445. ;  COPY & PASTE
  446. ; -----------------------------------------------------------
  447.  
  448. XICON 303 60 ":icn/Cut"
  449.     call gcview copy mypic myclip
  450.  
  451. XICON 303 75 ":icn/Paste"
  452.     ; paste myclip at EditBox x y as per mode
  453.     call gcview paste myclip mypic -1 -1 $fillmode
  454.     guiscreen gcview.gc front
  455.  
  456. XICON 363 45 ":icn/Build"
  457.     gosub gcview.g buildpic
  458.  
  459. ; -----------------------------------------------------------
  460. ;  MY STUFF...
  461. ; -----------------------------------------------------------
  462.  
  463. TEXT 393 75 86 15 "" 100 BOX            ; Clock - refreshed from s:gui/main.gc
  464.     gadid 27
  465.     gadtxt center
  466.  
  467. XICON 546 75 :icn/wbtog                    ; open/close bw
  468.     ifexists screen 'Workbench'
  469.         workbench close
  470.     else
  471.         workbench open
  472.     endif
  473.  
  474. XICON 606 75 :icn/DIR                    ; dir.gc
  475.     ifexists gui dir.gc
  476.         guiclose dir.gc
  477.         guiopen dir.gc
  478.     else
  479.         guiload guis:dir/dir.gc
  480.     endif
  481.     movescreen #this 0 12
  482.  
  483. XICON 516 75 :icn/DP                        ; dpaint
  484.     ifexists gui dpaintbar.gc
  485.         guiclose dpaintbar.gc
  486.         guiopen dpaintbar.gc
  487.     else
  488.         guiload s:gui/dpaintbar.gc
  489.     endif
  490.  
  491. XICON 483 75 ":icn/Build"                ; set as background (used to be de-interlace)
  492.     local w/h/temp
  493.  
  494.     ; resize to wb size..
  495.     call gcview info pubscreen Workbench
  496.     temp = $$call.ret
  497.     parsevar temp
  498.     if $$parse.total > 3
  499.         w = $$parse.2
  500.         h == $$parse.3 - $$parse.5  ; height-barheight
  501.     else
  502.         stop
  503.     endif
  504.     call gcview resize mypic $w $h
  505.  
  506.     ; set as bgd
  507.     CLI 'DH0:prefs/WBpattern FROM Hard:Prefs/Presets/WBPat.clear USE'
  508.     delay 2
  509.     call gcview save mypic ram:WBP
  510.     CLI 'DH0:prefs/WBpattern FROM Hard:Prefs/Presets/WBPat.set USE'
  511.  
  512.     ; clear..
  513.     call gcview unload #PIC
  514.     call gcview unload #ANIM
  515.  
  516.